<template>
  <t-image-viewer v-if="!store.isMobileType" v-model:visible="ImgVisible" :images="[urls + props.info.value]">
  </t-image-viewer>
  <van-image-preview :show-index="false" v-else v-model:show="ImgVisible" :images="[urls + props.info.value]">
  </van-image-preview>
  <div class="outline-parent">
    <img
      class="outline-parent-bg"
      v-if="props.info.value || (props.info.video && props.info.video.url)"
      :src="publicUrls + 'free/style13/Auxiliaryoutlinestyle3Bg.webp'"
      alt=""
    />
    <img class="outline-parent-bg2" v-else :src="publicUrls + 'free/style13/Auxiliaryoutlinestyle3Bg2.webp'" alt="" />
    <img
      class="outline-parent-shadow"
      v-if="props.info.value || (props.info.video && props.info.video.url)"
      :src="publicUrls + 'free/style13/Auxiliaryoutlinestyle3shadow.webp'"
      alt=""
    />
    <img
      class="outline-parent-shadow2"
      v-else
      :src="publicUrls + 'free/style13/Auxiliaryoutlinestyle3shadow2.webp'"
      alt=""
    />
    <div
      class="outline border-hover-style"
      :class="!props.info.value && !(props.info.video && props.info.video.url) && 'outline-flex'"
    >
      <div
        class="audio-box"
        :class="isPlay && 'audio-rotate'"
        v-if="props.info.audio && props.info.audio.url"
        @click="audioplay(true)"
      >
        <i class="doorIcon">&#xe688;</i>
      </div>
      <audio v-if="props.info.audio && props.info.audio.url" :src="urls + props.info.audio.url" ref="audioRef"></audio>

      <div class="outline-title" :class="!props.info.subTitle && !props.info.remarks && 'title-margin'">
        {{ props.info.text }}
      </div>
      <p class="outline-subTitle" v-if="props.info.subTitle">
        {{ props.info.subTitle }}
      </p>
      <TextMax
        v-if="props.domShow"
        :data="props.info.remarks"
        :title="props.info.text"
        :infoData="props.info"
        :row="
          (props.info.value || (props.info.video && props.info.video.url)) && props.info.subTitle
            ? 2
            : !(props.info.value || (props.info.video && props.info.video.url)) && props.info.subTitle
            ? 6
            : !props.info.subTitle && !props.info.value && !(props.info.video && props.info.video.url)
            ? 8
            : 2
        "
      ></TextMax>
      <div class="content-item" v-if="props.info.value || (props.info.video && props.info.video.url)">
        <div class="medium">
          <img
            v-if="props.info.value && !(props.info.video && props.info.video.url)"
            class="outline-cover"
            @click="ImgVisible = true"
            :src="urls + props.info.value + '?imageView2/3/w/898/h/460/format/webp'"
            alt=""
          />
          <videoview @click="audioplay(false)" :info="props.info"></videoview>
        </div>
      </div>
    </div>
  </div>
</template>

<script lang="ts">
export default defineComponent({
  name: 'free13Style3',
});
</script>

<script setup lang="ts">
import { publicUrls } from '@/utils/minxin';
import { useProjectStore } from '@/store';
import { urls } from '@/utils/request/upload';
import { defineComponent, ref } from 'vue';
import TextMax from '@/freeComponents/textMode/TextMax.vue';
import videoview from './../../../videoDialog/videoview.vue';

const props = defineProps({
  info: {
    type: Object,
  },
  domShow: {
    type: Boolean,
  },
});

const ImgVisible = ref(false);
const audioRef = ref(null);
const videoRef = ref(null);
const isPlay = ref(false);
const store = useProjectStore();
const audioplay = (flag: boolean = true) => {
  if (audioRef.value.paused && flag) {
    audioRef.value.play();
    if (videoRef.value) {
      videoRef.value.pause();
    }

    isPlay.value = true;
  } else {
    audioRef.value.pause();
    isPlay.value = false;
  }
};

const videoplay = () => {
  if (videoRef.value.paused) {
    videoRef.value.play();
    if (audioRef.value) {
      audioRef.value.pause();
    }

    isPlay.value = false;
  } else {
    videoRef.value.pause();
    isPlay.value = true;
  }
};
</script>

<style scoped lang="less">
.outline-parent {
  position: relative;
  -webkit-box-reflect: below 220px linear-gradient(transparent, rgba(0, 0, 0, 0.2));
  margin: 0 80px;
}
.outline-parent-bg {
  width: 900px;
  height: 496px;
  margin-top: 50px;
  margin-right: 10px;
}
.outline-parent-shadow {
  width: 908px;
  height: 494px;
  position: absolute;
  bottom: -5px;
  left: 5px;
  z-index: -1;
}
.outline-parent-bg2 {
  width: 730px;
  height: 496px;
  margin-top: 50px;
  margin-right: 10px;
}
.outline-parent-shadow2 {
  width: 738px;
  height: 494px;
  position: absolute;
  bottom: -5px;
  left: 5px;
  z-index: -1;
}
.outline {
  position: absolute;
  top: 50px;
  left: 0;
  z-index: 20;
  width: 900px;
  height: 496px;
  padding: 56px 212px 70px 144px;
  display: flex;
  align-items: center;
  flex-direction: column;
  overflow: hidden;
}
.outline-flex {
  width: 730px !important;
  height: 496px !important;
  padding: 80px 210px 106px 160px !important;
}
.outline-title {
  width: 100%;
  font-family: 'SourceHanSerifCN-Bold';
  font-size: 20px;
  color: #000000;
  line-height: 30px;
  text-align: center;
  margin-bottom: 8px;
}
.title-margin {
  margin-bottom: 24px !important;
}
.outline-subTitle {
  width: 100%;
  font-family: SourceHanSerifCN;
  font-size: 18px;
  color: #000000;
  line-height: 28px;
  text-align: center;
  margin-bottom: 24px;
}
.content-item {
  width: 100%;
  flex: 1;
  background: rgba(0, 0, 0, 0.4);
  overflow: hidden;
}
.medium {
  width: 100%;
  height: 100%;
  position: relative;
  overflow: hidden;
  &:hover .outline-cover {
    transform: scale(1.5);
  }
  ::v-deep .mask-layer {
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    position: absolute;
    top: 50%;
    transform: translate(0%, -50%);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1;
    .round {
      width: 40px;
      height: 40px;
      border-radius: 50%;
      border: 2px solid rgba(255, 255, 255, 1);
      text-align: center;
      .freeIcon {
        font-size: 24px;
        line-height: 38px;
        color: rgba(255, 255, 255, 1);
      }
    }
  }
  .outline-cover {
    width: 100%;
    height: 100%;
    object-fit: contain;
    overflow: hidden;
    transition: all 0.3s ease;
  }
}
.audio-rotate {
  animation: audio-rotate 3s linear infinite;
  @keyframes audio-rotate {
    0% {
      transform: rotate(0deg);
    }
    100% {
      transform: rotate(360deg);
    }
  }
}
.audio-box {
  position: absolute;
  bottom: 70px;
  right: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  background: url(https://static.jiyi.show/free/style13/3dIcon.webp) no-repeat center/100% 100%;
  padding-right: 5px;
  .doorIcon {
    width: 100%;
    height: 100%;
    color: #fff;
    font-size: 26px;
    line-height: 64px;
    text-align: center;
  }
}

::v-deep .textMore-box {
  margin-bottom: 24px;
}

::v-deep .van-text-ellipsis {
  font-family: PingFangSC !important;
  font-size: 16px !important;
  color: rgba(0, 0, 0, 0.6) !important;
  line-height: 32px !important;
}
::v-deep .van-text-ellipsis__action::before {
  color: #ff0505 !important;
  font-weight: 400 !important;
  text-decoration-line: underline;
}
</style>
